package czh.cocoa.graphics;

import android.graphics.Path;
import czh.cocoa.foundation.NSObject;
import czh.cocoa.ui.UIEdgeInsets;

public class CGPath extends NSObject {

	protected Path mPath;
	
	public CGPath() {
		mPath = new Path();
	}
	
	Path getPath() {
		return mPath;
	}
	
	//additional
	public static CGPath roundRectPath(CGRect rect, float rLT, float rRT, float rLB, float rRB) {
		CGMutablePath path = new CGMutablePath();
		
	    float x = rect.origin.x;
	    float y = rect.origin.y;
	    float width = rect.size.width;
	    float height = rect.size.height;
	    
	    path.moveToPoint(null, x, y + rLT);
	    path.addArc(null, x + rLT, y + rLT, rLT, M_PI, M_PI * 1.5f, 1);
	    path.addLineToPoint(null, x + width - rRT, y);
	    path.addArc(null, x + width - rRT, y + rRT, rRT, -M_PI_2, 0, 1); 
	    path.addLineToPoint(null, x + width, y + height - rRB); 
	    path.addArc(null, x + width - rRB, y + height - rRB, rRB, 0, M_PI_2, 1); 
		path.addLineToPoint(null, x + rLB, y + height);
		path.addArc(null, x + rLB, y + height - rLB, rLB, M_PI_2, M_PI, 1);
		path.closeSubpath();
	    
		return path;
	}
	
}
